import { UploadApiResult } from './model/uploadModel';
import { defHttp } from '@/utils/http/axios';
import { UploadFileParams } from '#/axios';
import { useGlobSetting } from '@/hooks/setting';
import { ErrorMessageMode } from '#/axios';

const { uploadUrl = '' } = useGlobSetting();
enum Api {
  // 上传页面删除文件接口
  deleteFile = "/minio/delete"
}
/**
 * @description: Upload interface
 */
export function uploadFiles(
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) {
  return defHttp.uploadFile<UploadApiResult>(
    {
      url: uploadUrl,
      onUploadProgress,
    },
    params,
  );
}
export const deleteFile = (params, mode: ErrorMessageMode = 'message') => {
  return defHttp.post<any>({ params,url: Api.deleteFile },
    {
      errorMessageMode: mode,
    },);
};